<template>
	<view class="content">
		<view class="top-bar">

			<view class="top-bar-left">
				<image src="../../static/images/img/one.png" mode=""></image>
			</view>
			<view class="top-bar-center">
				<image src="../../static/images/index/logo.png" mode=""></image>
			</view>
			<view class="top-bar-right">
				<view class="search">
					<image src="../../static/images/index/search.png" mode=""></image>
				</view>
				<view class="add">
					<image src="../../static/images/index/add.png" mode=""></image>
				</view>
			</view>
		</view>
		<view class="main">
			<view class="friends">
				<view class="friends-list">
					<view class="friends-list-left">
						<text class="tip">1</text>
						<image src="../../static/images/index/apply.png"></image>
					</view>
					<view class="friends-list-right">
						<view class="top">
							<view class="name">
								好友申请
							</view>
							<view class="time">
								13：43
							</view>
						</view>
						<view class="bottomContent">
							loremloremloremloremloremloremloremloremloremloremloremloremloremloremlorem
						</view>
					</view>
				</view>
			</view>
			<view class="friends" v-for="(item,i) in friends" :key="item.id">
				<view class="friends-list">
					<view class="friends-list-left">
						<text class="tip" v-show="item.tip>0">{{item.tip}}</text>
						<image :src="item.imgurl"></image>
					</view>
					<view class="friends-list-right">
						<view class="top">
							<view class="name">
								{{item.name}}
							</view>
							<view class="time">
								{{changeTime(item.time)}}
							</view>
						</view>
						<view class="bottomContent">
							{{item.news}}
						</view>
					</view>
				</view>
			</view>

		</view>

	</view>
</template>

<script>
	import datas from '../../commons/js/datas.js';
	import myfunc from '../../commons/js/myfunc.js'
	export default {
		data() {
			return {
				friends: []
			}
		},
		onLoad() {
			this.getFriends();
		},
		methods: {
			changeTime: function(data) {
				return myfunc.dateTime(data);
			},
			getFriends: function() {
				this.friends = datas.friends();
				for (let i = 0; i < this.friends.length; i++) {
					this.friends[i].imgurl = '../../static/images/img/' + this.friends[i].imgurl;
				}

			}
		}
	}
</script>

<style lang="scss">
	@import  "../../commons/css/index.scss";
	.content {
		padding-bottom: $uni-spacing-col-base;
	}

	.main {
		padding-top: 104rpx;
		width: 100%;
		box-sizing: border-box;

		.friends-list {
			height: 96rpx;
			padding: 16rpx $uni-spacing-col-base 16rpx;

			&:active {
				background: $uni-bg-color-grey;
			}

			.friends-list-left {
				position: relative;
				float: left;

				image {
					width: 96rpx;
					height: 96rpx;
					border-radius: $uni-border-radius-base;
					background-color: $uni-color-primary;
				}

				.tip {
					position: absolute;
					top: -8rpx;
					left: 68rpx;
					z-index: 10;
					height: 36rpx;
					padding: 0 8rpx;
					min-width: 20rpx;
					background: $uni-color-warning;
					border-radius: 18rpx;
					font-size: $uni-font-size-sm;
					color: $uni-text-color-inverse;
					line-height: 36rpx;
					text-align: center;
				}
			}

			.friends-list-right {
				padding-left: 128rpx;

				.top {
					height: 50rpx;

					.name {
						float: left;
						font-size: 36rpx;
						color: $uni-text-color;
						line-height: 50rpx;
					}

					.time {
						float: right;
						font-size: $uni-spacing-col-sm;
						color: $uni-text-color-disable;
						line-height: 50rpx;
					}
				}

				.bottomContent {
					font-size: $uni-font-size-base;
					color: $uni-text-color-grey;
					line-height: 40rpx;
					text-overflow: ellipsis;
					white-space: nowrap;
					overflow-x: hidden;
				}
			}
		}
	}
</style>
